
public class PrintNumbersThread implements Runnable{
	private String threadtype;  
	 
    public PrintNumbersThread(String threadtype) {
 
        this.threadtype = threadtype;
 
    }  
 
    @Override
 
    public void run() {  
 
        printNumbers(threadtype);  
 
    }  
 
    private void printNumbers(String threadtype) {  
 
        NumberType numtype = NumberType.valueOf(threadtype);
 
        switch (numtype) {  
 
        case EVEN:
 
            printEvenNumbers();
 
            break;
 
        case ODD:
 
            printOddNumbers();
 
            break;  
 
        }
 
    }  
 
    private void printOddNumbers() {
 
        for (int i = 0; i <= 20; i++) {
 
            if (i % 2 != 0) {
 
                System.out.println("O:" + i + " ");
 
            }
 
        }
 
    }  
 
    private void printEvenNumbers() {
 
        for (int i = 0; i <= 200; i++) {
 
            if (i % 2 == 0) {
 
                System.out.println("E:" + i + " ");
 
            }
 
        }  
 
    }  
}
